<template>
  <div class="home-container">
    <section class="hero-section">
      <div class="hero-content">
        <h1 class="hero-title">AI设计与绘画一站式平台</h1>
        <p class="hero-subtitle">释放创造力，让AI成为你的创意助手</p>
        <div class="hero-actions">
          <router-link to="/designer" class="primary-btn">
            <el-icon><Edit /></el-icon>
            开始设计
          </router-link>
          <router-link to="/templates/showcase" class="secondary-btn">
            <el-icon><PictureFilled /></el-icon>
            探索AI绘画
          </router-link>
        </div>
      </div>
    </section>

    <section class="features-section">
      <h2 class="section-title">功能特色</h2>
      <div class="features-grid">
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon><Brush /></el-icon>
          </div>
          <h3 class="feature-title">AI绘画</h3>
          <p class="feature-desc">通过强大的AI模型，将文字描述转换为精美图像</p>
        </div>
        
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon><Edit /></el-icon>
          </div>
          <h3 class="feature-title">设计工具</h3>
          <p class="feature-desc">简单易用的设计工具，快速创建专业级的设计作品</p>
        </div>
        
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon><Connection /></el-icon>
          </div>
          <h3 class="feature-title">融合创作</h3>
          <p class="feature-desc">将AI生成的图像与设计工具无缝结合，实现创意突破</p>
        </div>
        
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon><Share /></el-icon>
          </div>
          <h3 class="feature-title">分享与合作</h3>
          <p class="feature-desc">轻松分享你的作品，与社区用户进行创意交流</p>
        </div>
      </div>
    </section>

    <section class="templates-section">
      <div class="section-header">
        <h2 class="section-title">热门模板</h2>
        <router-link to="/templates/showcase" class="view-all">查看全部</router-link>
      </div>
      
      <div class="templates-grid">
        <div v-for="template in popularTemplates" :key="template.id" class="template-card">
          <div class="template-image">
            <img :src="template.image" :alt="template.name">
          </div>
          <div class="template-info">
            <h3 class="template-name">{{ template.name }}</h3>
            <p class="template-desc">{{ template.description }}</p>
            <div class="template-meta">
              <span class="template-author">{{ template.author }}</span>
              <span class="template-stats">
                <el-icon><Star /></el-icon> {{ template.likes }}
              </span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <section class="cta-section">
      <div class="cta-content">
        <h2 class="cta-title">开始你的创意之旅</h2>
        <p class="cta-desc">无论是创建营销素材、电子商务图片，还是个人艺术作品，我们都能满足你的需求</p>
        <router-link to="/designer" class="cta-button">立即开始</router-link>
      </div>
    </section>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { Edit, PictureFilled, Brush, Connection, Share, Star } from '@element-plus/icons-vue';

// 热门模板数据
const popularTemplates = ref([
  {
    id: 1,
    name: '电子商务产品展示',
    description: '专为电商平台设计的产品展示模板，突出产品特点',
    author: '设计团队',
    likes: 128,
    image: 'https://picsum.photos/id/1/400/300'
  },
  {
    id: 2,
    name: '梦幻风景',
    description: '使用AI生成梦幻般的自然风景，适合背景和艺术创作',
    author: 'AI艺术家',
    likes: 95,
    image: 'https://picsum.photos/id/10/400/300'
  },
  {
    id: 3,
    name: '科技概念图',
    description: '未来科技风格的概念图模板，适合科技产品和创新项目',
    author: '科技设计',
    likes: 84,
    image: 'https://picsum.photos/id/20/400/300'
  },
  {
    id: 4,
    name: '角色设计',
    description: '创建独特的动漫风格角色，可用于游戏、插画等项目',
    author: '角色设计师',
    likes: 132,
    image: 'https://picsum.photos/id/30/400/300'
  }
]);
</script>

<style scoped>
.home-container {
  width: 100%;
}

/* 英雄区域 */
.hero-section {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  padding: 80px 20px;
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 1.25rem;
  margin-bottom: 32px;
  opacity: 0.9;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-decoration: none;
}

.primary-btn {
  background-color: white;
  color: #6366f1;
}

.secondary-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  backdrop-filter: blur(4px);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.secondary-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* 功能特色区域 */
.features-section {
  padding: 80px 20px;
  background-color: #f9fafb;
}

.section-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 48px;
  color: #1f2937;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.feature-card {
  background-color: white;
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  width: 64px;
  height: 64px;
  background-color: #f3f4f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.feature-icon .el-icon {
  font-size: 28px;
  color: #6366f1;
}

.feature-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1f2937;
}

.feature-desc {
  color: #6b7280;
  line-height: 1.6;
}

/* 模板区域 */
.templates-section {
  padding: 80px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.view-all {
  color: #6366f1;
  font-weight: 500;
  text-decoration: none;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.template-card {
  background-color: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.template-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
}

.template-image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.template-info {
  padding: 20px;
}

.template-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1f2937;
}

.template-desc {
  color: #6b7280;
  font-size: 0.875rem;
  margin-bottom: 16px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: #6b7280;
}

.template-stats {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* CTA区域 */
.cta-section {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  padding: 80px 20px;
  text-align: center;
}

.cta-content {
  max-width: 700px;
  margin: 0 auto;
}

.cta-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.cta-desc {
  font-size: 1.125rem;
  opacity: 0.9;
  margin-bottom: 32px;
  line-height: 1.6;
}

.cta-button {
  display: inline-block;
  background-color: white;
  color: #4f46e5;
  padding: 12px 32px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-decoration: none;
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* 响应式布局 */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .feature-card,
  .template-card {
    transform: none !important;
  }
}
</style>